package jihe;

/**
 * 发牌没排序
 */

import java.util.ArrayList;
import java.util.Collections;
/**
 * 斗地主发牌器
 */
public class DouDiZhu01 {
    ArrayList arrayList = new ArrayList();
    /**
     * 初始化54张牌
     */
    public void init() {
        arrayList.add("大王");
        arrayList.add("小王");
        String [] numbers = {"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
        String [] colors = {"♠","♥","♣","♦"};
        for (int i = 0; i < numbers.length; i++) {
            for (int j = 0; j < colors.length; j++) {
                arrayList.add(colors[j]+numbers[i]);
            }
        }
    }
    /**
     * 洗牌
     */
    public void ShuffleCards(){
        Collections.shuffle(arrayList);
    }
    /**
     * 发牌
     */
    public void LicensePlate(){
        ArrayList gamer1 = new ArrayList();
        ArrayList gamer2 = new ArrayList();
        ArrayList gamer3 = new ArrayList();
        ArrayList hand = new ArrayList();
        for (int i = 0; i < arrayList.size(); i++) {
            if (i >= arrayList.size() - 3) {
                hand.add(arrayList.get(i));
            } else if (i % 3 == 0) {
                gamer1.add(arrayList.get(i));
            } else if (i % 3 == 1) {
                gamer2.add(arrayList.get(i));
            } else if (i % 3 == 2) {
                gamer3.add(arrayList.get(i));
            }
        }
        System.out.println("第一个玩家的牌：" + gamer1);
        System.out.println("第二个玩家的牌：" + gamer2);
        System.out.println("第三个玩家的牌：" + gamer3);
        System.out.println("底牌：" + hand);
    }
    public static void main(String[] args) {
        DouDiZhu01 douDiZhu = new DouDiZhu01();
        douDiZhu.init();
        douDiZhu.ShuffleCards();
        douDiZhu.LicensePlate();
    }
}
